<?php
/**
 * Created by PhpStorm.
 * User: xutao
 * Date: 2018/8/6
 * Time: 13:41
 * 引导页
 */
namespace app\admin\controller;
use app\common\model\BpModel;

class Bp extends Base{
    public function index(){
        $data = BpModel::order('update_time desc')->find();
        $this->assign('data',$data);
        return $this->fetch();
    }
    //更换图片
    public function edit_src(){
        if(request()->isAjax()){
            $src = input('src');
            $id = input('id');
            if(!$src || !$id) return json(['code'=>1,'data'=>'','msg'=>'参数错误']);
            $model = BpModel::get($id);
            $re = $model->save(['src'=>$src]);
            if($re){
                return json(['code'=>200,'data'=>'','msg'=>'更新成功']);
            }else{
                return json(['code'=>2,'data'=>'','msg'=>'更新失败']);
            }
        }else{
            return json(['code'=>0,'data'=>'','msg'=>'非法请求']);
        }
    }


}
